package com.javasm.dao.MisMannageDao.impl;

import com.javasm.dao.MisMannageDao.EditPwdDao;
import com.javasm.entity.MisMannageEntity.User;
import com.javasm.util.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author:JAVASM
 * @description:
 * @date:16:51
 * @version:0.1
 * @since:jdk11
 */
public class EditPwdDaoImpl implements EditPwdDao {
    @Override
    public Integer Edit(User insertUser) {
        Connection conn = JDBCUtil.getConn();
        PreparedStatement ps=null;
        ResultSet rs=null;
        Integer result=0;
        String sql=" update tb_user set user_pwd=?  where user_name=? ";
        //  System.out.println(sql);
        try {
            ps=conn.prepareStatement(sql);

            ps.setString(1,insertUser.getUserPwd());
            ps.setString(2,insertUser.getUserName());
            result=ps.executeUpdate();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.closeConn(conn, ps,null, rs);
        }
        return result;
    }
}
